<!--  -->
<template>
  <div :class="['tab-list',className]" :style="{'justify-content':level?'flex-start':'center' }">
    <div
      :class="index==current?'active item':'item'"
      :style="level?'':{flex:1}"
      v-for="(item,index) in list"
      :key="index"
      @click="ChangeTab(index)"
    >{{item}}</div>
  </div>
</template>

<script>
export default {
  name: 'tab',
  props: {
    //传过来的的calss名称 activeBlack activeBlue
    className: {
      type: String,
      default: "activeBlack"
    },
    list: {
      type: Array,
      default: () => []
    },
    current: {
      type: Number,
      default: 0
    },
    level: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      num: 0
    };
  },

  components: {},

  computed: {},

  methods: {
    ChangeTab (i) {
      this.$emit('click', i)
    }
  }
}

</script>
<style lang='scss' scoped>
.tab-list {
  display: flex;
  align-items: center;
}
.item {
  // padding-bottom: 15rpx;
  text-align: center;
}
.active {
  position: relative;
  &::after {
    content: '';
    position: absolute;
    bottom: 5rpx;
    left: 50%;
    transform: translateX(-50%);
  }
}
// 第一种样式
.activeBlack {
  background: #fff;
  .item {
    padding: 0 20rpx 15rpx;
    color: $font-small-gray;
    font-size: 30rpx;
  }
  .active {
    color: $font-color;
    font-weight: bold;
    &::after {
      width: 19rpx;
      height: 11rpx;
      background: $theme-color;
      border-radius: 20rpx;
    }
  }
}
// 第二种样式
.activeBlue {
  .item {
    padding: 35rpx 0;
    font-size: 30rpx;
    color: #444;
    line-height: 1;
  }
  .active {
    color: $theme-color;
    &::after {
      width: 40rpx;
      height: 7rpx;
      background: $theme-color;
    }
  }
}
</style>